package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type User struct {
	ID   string `uri:"id" binding:"required,uuid"`
	Name string `uri:"name" binding:"required"`
}

func main() {
	r := gin.Default()
	r.GET("/bind-uri/:id/:name", func(ctx *gin.Context) {
		var user User
		if err := ctx.ShouldBindUri(&user); err != nil {
			ctx.JSON(http.StatusBadRequest, gin.H{"msg": err.Error()})
			return
		}
		ctx.JSON(http.StatusOK, gin.H{"id": user.ID, "name": user.Name})
	})
	r.Run()
}
